package agenceVoyageVirtuel.client;

import agenceVoyageVirtuel.client.beans.ClientData;
import agenceVoyageVirtuel.client.control.ZoneDeTravail;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.ScrollPanel;

import agenceVoyageVirtuel.client.control.EspacePersoPanier;
import agenceVoyageVirtuel.client.control.BarreRecherche;
import agenceVoyageVirtuel.client.control.HeaderPanel;
import agenceVoyageVirtuel.client.control.MenuContextuel;
import agenceVoyageVirtuel.client.control.MenuLateral;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.TextBox;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Agence_voyage_virtuel implements EntryPoint {
	private ClientData client = null;
	private ZoneDeTravail zoneDeTravail;

	public void onModuleLoad() {
		RootPanel rootPanel = RootPanel.get();
		rootPanel.setStyleName("root");
		rootPanel.setSize("100%", "100%");
		
		DockPanel dockLayoutPanel = new DockPanel();
		ScrollPanel scrollPanel= new ScrollPanel(dockLayoutPanel);
		scrollPanel.setSize("100%", "100%");
		dockLayoutPanel.setStyleName("cadre");
		rootPanel.add(scrollPanel, 0, 0);
//		dockLayoutPanel.setSize("100%", "100%");
		
		HeaderPanel headerPanel = new HeaderPanel(this);
		dockLayoutPanel.add(headerPanel, DockPanel.NORTH);
		
		MenuLateral menuLateral = new MenuLateral(this);
		dockLayoutPanel.add(menuLateral, DockPanel.WEST);
		
		zoneDeTravail = new ZoneDeTravail(this);
		dockLayoutPanel.add(zoneDeTravail,DockPanel.CENTER);
		zoneDeTravail.setWidth("100%");
//		zoneDeTravail.setSize("100%", "100%");
		
		zoneDeTravail.getListPacksViewer().initPacks();
	}

	public void login(ClientData result) {
		this.client = result;
		if(isLogged())
			changeToLogged();
		else 
			changeToNotLogged();
	}

	private void changeToNotLogged() {
		zoneDeTravail.changeToNotLogged();
	}

	private void changeToLogged() {
		zoneDeTravail.changeToLogged();
	}

	public void selectDefaultView() {
		zoneDeTravail.selectdefaultView();
	}

	public boolean isLogged() {
		return client!=null;
	}
}
